package cn.kongwg.utils;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

/**
 * @author cn.kongwg
 * @create 2021-02-07 21:35
 */
public class MybaitsUtils {

    private static SqlSessionFactory sqlSessionFactory;

    static {
        InputStream is = MybaitsUtils.class.getClassLoader().getResourceAsStream("mybatis-config.xml");

        sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);

    }

    /**
     * 返回数据池连接
     * @return
     */
    public static SqlSession getSqlSession() {
        return sqlSessionFactory.openSession();
    }



}
